import { useTable, LIST_TYPE } from '@crud/index';
import { maps } from '@/config/index';
import { getPromoteLinkList } from '@/api/crm-agency/ad/lecturer';

// 查询
const statusMap: Record<string, any> = {
  1: '使用中',
  2: '已失效'
};

export const channelMap: Record<string, any> = {
  1: '微信',
  2: '抖音',
  3: 'Web'
};

export const productValMap = {
  '周卡': 'W1T1',
  '双周卡': 'W2T1',
  '月卡': 'M1T1'
};
// 表格
export const useTableList = (options: any = {}) => {
  const columns: any = [
    { label: '推广链接', prop: 'extend_url', minWidth: 160, tooltip: true, fixed: 'left' },
    // { label: '渠道', prop: 'channel', minWidth: 120, render: (s: any) => channelMap[s.row.channel] },
    { label: '兑换时长', prop: 'vip_type', minWidth: 120 },
    { label: '会员版本', prop: 'vip_level', width: 120, render: (s: any) => s.row.vip_level && maps.optionsAdPromoteLinkVipLevels[s.row.vip_level] },
    { label: '链接状态', prop: 'status', minWidth: 160, render: (s: any) => statusMap[s.row.status] },
    { label: '生成时间', prop: 'add_time', minWidth: 177, type: 'dateTime' },
    { label: '失效时间', prop: 'invalid_time', minWidth: 177, type: 'dateTime' },
    { label: '操作', prop: 'actions', width: 160, render: 'actions', fixed: 'right' }
  ];

  return useTable({
    ...options,
    type: LIST_TYPE.AGENCY,
    params: {
      agent_id: undefined
    },
    columns: columns,
    getList: getPromoteLinkList
  });
};
